#include <stdio.h>

#include <algorithm>
#include <string>

using namespace std;

int main() {
  for (int i = 1000; i <= 9999; ++i) {
    char buf[10];
    sprintf(buf, "%d", i);
    string a(buf), b(buf);
    reverse(a.begin(), a.end());
    if (a == b) {
      printf("%d\n", i);
    }
  }
  return 0;
}